import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;
import org.slf4j.LoggerFactory;

/**
 * 日志管理对象
 * @author yangfeng
 */
public class LogManager {

    public static void init(String logConfigFile) {
        System.out.println("Start LogBack Load ...");
        LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
        try {
            System.out.println("[LogBack] Config File is " + logConfigFile);
            JoranConfigurator configurator = new JoranConfigurator();
            configurator.setContext(lc);
            lc.reset();
            configurator.doConfigure(logConfigFile);
            //System.out.println("[LogBack] Context Property 'Log_Home' is " + lc.getProperty("Log_Home"));
        } catch (JoranException e) {
            e.printStackTrace();
            System.out.println("[FATAL] Logback Init Exception, System Exit !!!");
            System.exit(-1);
        }
        System.out.println("LogBack Load End!");
    }
}

